import request from '@/utils/request'
import basePath from '../apiConifg'
const qs = require('qs')
export function getMenus(params) {
  return request({
    url: basePath + '/sys/sys-menu/list?' + qs.stringify(params, { indices: false }),
    method: 'get'
  })
}

/**
 * 属性菜单，一次性返回
 * @param params
 */
export function menusTree(params) {
  return request({
    url: basePath + '/sys/sys-menu/tree?' + qs.stringify(params, { indices: false }),
    method: 'get'
  })
}

/**
 * 用户登录后，初始化
 * @param params
 */
export function init(params) {
  return request({
    url: basePath + '/sys/sys-menu/init?' + qs.stringify(params, { indices: false }),
    method: 'get'
  })
}

/**
 * 获取系统菜单资源目录-id-详情
 * @param params
 */
export function info(id) {
  return request({
    url: basePath + '/sys/sys-menu/' + id,
    method: 'get'
  })
}

export function getMenuMsgNum(params) {
  return request({
    url: '/sysMenu/getMsgNum',
    method: 'get',
    params
  })
}

export function add(data) {
  return request({
    url: basePath + '/sys/sys-menu',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: basePath + '/sys/sys-menu',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: basePath + '/sys/sys-menu',
    method: 'put',
    data
  })
}

export default { add, edit, del, info }
